import urllib2
from HTMLParser import HTMLParser
import sys

reload(sys)
sys.setdefaultencoding("utf-8")

class myHTMLParser(HTMLParser):

    def __init__(self):
        self.key = ""
        self.state = 0
        self.reset()

    def handle_starttag(self, tag, attrs):
        if tag=='span' and ('class','conName') in attrs:
            self.state = 1

    def handle_data(self, data):
        if self.state == 1:
            self.state = 2

        if self.state == 2:
            print data

    def handle_endtag(self, tag):
        if self.state==2:
            self.state = 0
            self.key = ""

url='http://www.smzdm.com'
data = urllib2.urlopen(url)

htmlp = myHTMLParser()
htmlp.feed(data.read())






